{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "d49c9785",
   "metadata": {},
   "source": [
    "> 1. c传递一个文本到指定的路由URL界面 \n",
    "> 2. 传递一个HTML的文本信息到指定路由URL界面 \n",
    ">> 1. 思考： 如果\"return\"会显得HTML代码很多，且写在了PYTHON文件当中；\n",
    ">> 2. 思考： 如果前(HTML)后(PYTHON)端可以分开两个文件（前后端分离）就比较好了；\n",
    ">> 3. 结论： 使用render_template方法实现前后端分离"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "fa6c2201",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " * Serving Flask app '__main__'\n",
      " * Debug mode: off\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.\n",
      " * Running on http://127.0.0.1:5000\n",
      "Press CTRL+C to quit\n",
      "127.0.0.1 - - [11/Dec/2023 19:40:01] \"GET / HTTP/1.1\" 200 -\n",
      "127.0.0.1 - - [11/Dec/2023 19:40:01] \"GET /favicon.ico HTTP/1.1\" 404 -\n",
      "127.0.0.1 - - [11/Dec/2023 19:40:18] \"GET /index HTTP/1.1\" 200 -\n"
     ]
    }
   ],
   "source": [
    "from flask import Flask\n",
    "app = Flask(__name__)\n",
    "\n",
    "@app.route('/')\n",
    "def hello_world():\n",
    "    return 'Hello, World'\n",
    "@app.route('/index')\n",
    "def index():\n",
    "    return'<h1>这是我的Python期末项目</h1>'\n",
    "\n",
    "app.run()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "eff19bec",
   "metadata": {},
   "source": [
    "# 2. 创建Flask应用，实现静态页面的开发"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f6e5b8e5",
   "metadata": {},
   "outputs": [],
   "source": [
    "from flask import Flask\n",
    "from flask import render_template\n",
    "app = Flask(__name__)\n",
    "\n",
    "\n",
    "@app.route('/')\n",
    "def hello_world():\n",
    "    return render_template('index.html')\n",
    "\n",
    "app.run()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0db08971",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
